var e = require;
var t = module;
var o = exports;
var ii, nn = this && this.__extends || (ii = function (t, e) {
    return (ii = Object.setPrototypeOf || {
        __proto__: []
    }
        instanceof Array &&
        function (t, e) {
            t.__proto__ = e
        } ||
        function (t, e) {
            for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o])
        })(t, e)
},
    function (t, e) {
        function o() {
            this.constructor = t
        }
        ii(t, e),
            t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o)
    }
),
    rr = this && this.__awaiter ||
        function (t, e, o, i) {
            return new (o || (o = Promise))(function (n, a) {
                function r(t) {
                    try {
                        l(i.next(t))
                    } catch (e) {
                        a(e)
                    }
                }
                function s(t) {
                    try {
                        l(i.
                            throw(t))
                    } catch (e) {
                        a(e)
                    }
                }
                function l(t) {
                    var e;
                    t.done ? n(t.value) : (e = t.value, e instanceof o ? e : new o(function (t) {
                        t(e)
                    })).then(r, s)
                }
                l((i = i.apply(t, e || [])).next())
            })
        };
var oo = (this && this.__decorate) ||
    function (e, t, a, n) {
        var i,
            o = arguments.length,
            s = o < 3 ? t : null === n ? (n = Object.getOwnPropertyDescriptor(t, a)) : n;
        if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) s = Reflect.decorate(e, t, a, n);
        else
            for (var r = e.length - 1; r >= 0; r--)
                (i = e[r]) && (s = (o < 3 ? i(s) : o > 3 ? i(t, a, s) : i(t, a)) || s);
        return o > 3 && s && Object.defineProperty(t, a, s), s;
    };
Object.defineProperty(o, "__esModule", { value: !0 });
var a = e("EventManager"),
    n = e("AudioManager"),
    i = e("UIManager"),
    r = e("AD"),
    s = cc._decorator,
    l = s.ccclass,
    _ =
        (s.property,
            (function (e) {
                function t() {
                    var t = (null !== e && e.apply(this, arguments)) || this;
                    return (t.uiManager = null), (t.bindEventDic = {}), t;
                }
                return (
                    nn(t, e),
                    (t.prototype.onLoad = function () {
                        this.onLoadInfo();
                        for (var e = this.node.getComponentsInChildren(cc.Button), t = 0; t < e.length; t++)
                            e[t].node.on("click", this.OnClick, this);
                    }),
                    (t.prototype.onLoadInfo = function () { }),
                    (t.prototype.onEnable = function () {
                        this.showView(), this.initView(), this.addEvent();
                    }),
                    (t.prototype.showView = function () { }),
                    (t.prototype.initView = function () {
                        this.uiManager = cc.find("UIManager").getComponent(i.default);
                    }),
                    (t.prototype.addEvent = function () { }),
                    (t.prototype.removeEvent = function () { }),
                    (t.prototype.OnClick = function () {
                        n.default.ButtonSound();
                    }),
                    (t.prototype.emitEvent = function (e, t) {
                        a.EventManager.raiseEvent(e, t);
                    }),
                    (t.prototype.attachEvent = function (e, t, o) {
                        this.bindEventDic[e] ||
                            ((this.bindEventDic[e] = { func: t, target: o }),
                                o ? a.EventManager.addEventListener(e, t, o) : a.EventManager.addEventListener(e, t));
                    }),
                    (t.prototype.detachEvents = function () {
                        for (var e in this.bindEventDic) {
                            var t = this.bindEventDic[e];
                            t.target
                                ? a.EventManager.removeEventListener(e, t.func, t.target)
                                : a.EventManager.removeEventListener(e, t.func);
                        }
                        this.bindEventDic = {};
                    }),
                    (t.prototype.closePopup = function () {
                        (this.node.active = !1),
                            (this.node.zIndex = -1),
                            r.default.getInstance().hideCustomAd(),
                            this.detachEvents();
                    }),
                    (t.prototype.onDisable = function () {
                        this.removeEvent(), this.detachEvents();
                    }),
                    oo([l], t)
                );
            })(cc.Component));
o.default = _;
